# 假设的实际人口数据
import numpy as np

actual_data = np.array([1000, 1020, 1041, 1062, 1084, 1107, 1130, 1154, 1179, 1205,
                        1231, 1258, 1286, 1314, 1343, 1373, 1404, 1436, 1469, 1503,
                        1538, 1574, 1611, 1649, 1688, 1728, 1770, 1813, 1857, 1903])

# 指数增长模型预测
N0 = actual_data[0]
r = 0.02
t = np.arange(30)

N_exponential = N0 * np.exp(r * t)
mse_exponential = np.mean((N_exponential - actual_data) ** 2)

# Logistic增长模型预测
K = 20000
N_logistic = K / (1 + ((K - N0) / N0) * np.exp(-r * t))
mse_logistic = np.mean((N_logistic - actual_data) ** 2)

print(f"指数增长模型均方误差: {mse_exponential}")
print(f"Logistic增长模型均方误差: {mse_logistic}")

